package com.asj.house.controller;


import com.asj.house.returns.RespEntity;
import com.asj.house.service.HouseRoomIntermediaryService;
import com.asj.house.vo.CheckBoxVO;
import com.asj.house.vo.TreeVO;
import io.swagger.annotations.Api;
import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 房屋中介关系表 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-03-16
 */
@RestController
    @RequestMapping("/house-room-intermediary")
@Slf4j
@Api(value = "中介房源接口", tags = "中介房源接口")
public class HouseRoomIntermediaryController {

    @Resource
    private HouseRoomIntermediaryService houseRoomIntermediaryService;

    @GetMapping("/checkBox")
    @ApiOperation(value = "房源分配中介复选框格式")
    @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "roomId", value = "房源id", required = true)
    public RespEntity<List<CheckBoxVO>> listCheckBoxVO(@RequestParam(value = "roomId", required = true) Integer roomId) {
        RespEntity<List<CheckBoxVO>> respEntity = houseRoomIntermediaryService.listCheckBoxVO(roomId);
        return respEntity;
    }

    @PutMapping("/update")
    @ApiOperation(value = "分配房源")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "ids", value = "中介ids, 逗号间隔", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "roomId", value = "房源id", required = true)
    })
    public RespEntity updateHouseRoomIntermediary(@RequestParam(value = "ids", required = true) String ids,
                                                  @RequestParam(value = "roomId", required = true) Integer id) {
        RespEntity respEntity = houseRoomIntermediaryService.updateIntermediary(ids, id);
        return respEntity;
    }

    @GetMapping("/tree")
    @ApiOperation(value = "房源分配树形展示")
    public RespEntity listTree() {
        RespEntity<List<TreeVO>> respEntity = houseRoomIntermediaryService.listTreeVO();
        return respEntity;
    }
}
